package com.example.mymicaihu.adapter.home;

import android.content.Context;
import android.widget.TextView;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.mymicaihu.R;
import com.example.mymicaihu.bean.FocusNewsBean;

import java.util.List;

/**
 * 作者：朱勇闯
 * data : 2021/4/25  17:02
 * 作用： xxxx
 */
public class FocusNewsAdapter extends BaseAdapter<FocusNewsBean.DataBean> {
    public ItemListener itemListener;

    public void setItemListener(ItemListener itemListener) {
        this.itemListener = itemListener;
    }

    public FocusNewsAdapter(List<FocusNewsBean.DataBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, FocusNewsBean.DataBean listBean, int position) {
        TextView title = holder.getView(R.id.tv_title_focusnews);
        RecyclerView rv_list = holder.getView(R.id.rv_list_focusnews);
        title.setText(listBean.getDate());

        rv_list.setLayoutManager(new LinearLayoutManager(context));
        FocusNewsListAdapter listAdapter = new FocusNewsListAdapter(listBean.getNews(), context, R.layout.item_focuslist);
        rv_list.setAdapter(listAdapter);
        rv_list.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    }

    public interface ItemListener {
        void onItemClickListener(int pos);
    }
}
